﻿using Framework.Scene;
using Framework.UI;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

namespace BridgeShips {

    
    public class StartUI : UIBase {

        private Button btn_in;
        private Vector4 m_screenResolution;
        public Image m_backGroundImage;

        //private Animator anim;
        //private bool b = false;
        void Start() {
            btn_in = transform.Find( "Meticulous Lock/lock" ).GetComponent<Button>();
            btn_in.onClick.AddListener( Click );

            //anim = transform.Find( "Meticulous Lock/lock" ).GetComponent<Animator>();

            //m_screenResolution = new Vector4( 1920, 1080, 0, 0 );
            m_screenResolution = new Vector4( Screen.width, Screen.height, 0, 0 );
            if (m_backGroundImage != null) {
                m_backGroundImage.material.SetVector( "iResolution", m_screenResolution );
            }
        }

        private void Click() {
            StartCoroutine( Load() );
          
        }

        private IEnumerator Load() {
            yield return new WaitForSeconds( 1.0f );
            //跳转场景   
            UnityEngine.SceneManagement.SceneManager.LoadScene( "loading" );
        }

        // Update is called once per frame
        void Update() {
            //AnimatorStateInfo animator = anim.GetCurrentAnimatorStateInfo( 0 );
            //if (animator.normalizedTime > 1.0f) {
            //    b = true;
            //}

            if (m_backGroundImage != null) {
                m_backGroundImage.material.SetVector( "iResolution", m_screenResolution );
            }
        }
    }
}
